<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:doc="livcos.org/ns/doc"
  xmlns="http://www.w3.org/1999/XSL/Format"
  exclude-result-prefixes="doc">

  <xsl:template match="doc:list">
    <list-block space-before="4pt" space-after="4pt">
      <xsl:if test="not(ancestor::doc:list)">
        <xsl:attribute name="margin-left">8mm</xsl:attribute>
      </xsl:if>
      <xsl:apply-templates select="doc:item" />
    </list-block>
  </xsl:template>

	<xsl:template match="doc:item">
		<list-item space-after="2pt">
      <list-item-label>
        <block font-family="serif">
          <xsl:variable name="level" select="count(ancestor::doc:list)"/>
          <xsl:choose>
            <xsl:when test="../@type = 'ordered'">
              <xsl:number/><xsl:text>.</xsl:text>
            </xsl:when>
            <xsl:when test="$level = 1">
              <xsl:text>&#x2022;</xsl:text>
            </xsl:when>
            <xsl:when test="$level = 2">
              <xsl:text>&#x2022;</xsl:text>
            </xsl:when>
            <xsl:when test="$level = 3">
              <xsl:text>&#x2022;</xsl:text>
            </xsl:when>
            <xsl:when test="$level = 4">
              <xsl:text>&#x2022;</xsl:text>
            </xsl:when>
            <xsl:otherwise>
              <xsl:text>&#x2022;</xsl:text>
            </xsl:otherwise>
          </xsl:choose>
        </block>
      </list-item-label>
      <list-item-body>
      	<block margin-left="3mm">
      		<xsl:apply-templates select="node()" mode="list_content"/>
      	</block>
      </list-item-body>
    </list-item>
  </xsl:template>

	<xsl:template match="*" mode="list_content">
		<xsl:apply-templates select="."/>
	</xsl:template>
	
	<xsl:template match="doc:paragraph" mode="list_content">
		<block margin-left="0mm" margin-top="0pt" margin-right="4mm" margin-bottom="4pt">
			<xsl:apply-templates select="node()"/>
		</block>
	</xsl:template>
	
</xsl:stylesheet>
